//
//  GKZYMyInfoDataTableViewCell.m
//  GKZY_CLASS
//
//  Created by chenziqiang on 15/12/5.
//  Copyright © 2015年 eenet. All rights reserved.
//

#import "GKZYMyInfoDataTableViewCell.h"
#import "GKZYMyInfoModel.h"
#import <Masonry/Masonry.h>


@interface GKZYMyInfoDataTableViewCell ()
@property (nonatomic, strong) UIImageView *headImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UILabel *lineLabel;
@end
@implementation GKZYMyInfoDataTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.headImageView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.detailLabel];
        [self addSubview:self.lineLabel];
    }
    return self;
}

#pragma mark - Property Setter
- (void)setModel:(GKZYMyInfoModel *)model{
    _model = model;
//    if (model.isHeader) {
//        self.headImageView.hidden = NO;
//        self.detailLabel.hidden = YES;
//        self.headImageView.image = model.headImage;
//        [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerY.equalTo(self.contentView.mas_centerY);
//            make.right.equalTo(self.contentView.mas_right).offset(-12);
//            make.size.mas_equalTo(CGSizeMake(40, 40));
//        }];
//        
//    }else{
//        self.headImageView.hidden = YES;
//        if (model.detail && model.detail.length > 0) {
//            self.detailLabel.hidden = NO;
//            self.detailLabel.text = model.detail;
//        }
//        [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerY.equalTo(self.contentView.mas_centerY);
//            make.right.equalTo(self.contentView.mas_right).offset(-25);
//            make.height.mas_equalTo(@20);
//            make.left.equalTo(self.contentView.mas_centerY);
//        }];
//        
//    }
//    self.titleLabel.text = model.title;
//    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(self.contentView.mas_centerY);
//        make.height.mas_equalTo(@20);
//        make.left.equalTo(self.contentView.mas_left).offset(12);
//        make.right.equalTo(self.contentView.mas_centerX);
//    }];
//    
//    [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.right.bottom.equalTo(self);
//        make.height.mas_equalTo(@0.8);
//    }];
}

#pragma mark - Property Getter
- (UIImageView *)headImageView{
    if (!_headImageView) {
        _headImageView = ({
            UIImageView *imageView = [UIImageView new];
            imageView.layer.masksToBounds = YES;
            imageView.layer.cornerRadius = 40/2.f;
            imageView;
        });
    }
    return _headImageView;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = ({
            UILabel *title = [UILabel new];
            title.font = [UIFont systemFontOfSize:16];
            title.textColor = [UIColor colorWithRed:70/255.f green:70/255.f blue:70/255.f alpha:1];
            title;
        });
    }
    return _titleLabel;
}

- (UILabel *)detailLabel{
    if (!_detailLabel) {
        _detailLabel = ({
            UILabel *title = [UILabel new];
            title.font = [UIFont systemFontOfSize:16];
            title.textAlignment = NSTextAlignmentRight;
            title.textColor = [UIColor colorWithRed:153/255.f green:153/255.f blue:153/255.f alpha:1];
            title;
        });
    }
    return _detailLabel;
}

- (UILabel *)lineLabel{
    if (!_lineLabel) {
        _lineLabel = ({
            UILabel *title = [UILabel new];
            title.backgroundColor = [UIColor colorWithRed:222/255.f green:222/255.f blue:222/255.f alpha:1];
            title;
        });
    }
    return _lineLabel;
}
@end
